//点击头部跳转首页
$(".headerUl li").each(function(i,n){
    $(n).click(function(){
        window.location.href="../index.html"
    })
})
$("#login").click(function(){
    window.location.href="../html/login.html"
})
$("#join").click(function(){
    window.location.href="../html/join.html"
})
$("#joinBtn").click(function(){
    var usertel=$("#usertel").val();
    var telReg=/^1[35678][0-9]{9}$/g;
    var userpwd=$("#userpwd").val();
    var repeatpwd=$("#repeatPwd").val();
    
    var usertelFlg=checkStrByReg(telReg,usertel,$("#judgetel"));
    if(userpwd==repeatpwd){
        $("#judegpwd2").css("display","none");
        var pwdReg=/^[a-z0-9]{5,11}$/ig;
        var userpwdFlg=checkStrByReg(pwdReg,userpwd,$("#judegpwd1"));
    }else{
        $("#judegpwd2").css({"display":"inline-block","color":"red"});
    }
    if(usertelFlg&&userpwdFlg){
        $.ajax({
            type: "get",
            url: "../php/join.php",
            data: {"usertel":usertel,"userpwd":userpwd},
            dataType: "json",
            success: function (obj) {
                if(obj.code==1){
                    window.location.href="login.html";
                }else{
                    alert(obj.msg);
                }
            }
        });
        
    }else{
        alert("注册失败")
    }
    
    

})
function checkStrByReg(reg,str,obj){
    if(reg.test(str)){
        obj.css("display","none");
        return true;
    }else{
        obj.css({"display":"inline-block","color":"red"})
        return false;
    }
}